get content
Retrieve specific content from TabNews API by providing username and slug parameters to access articles or posts.
Instructions
get content from tabnews api
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| username | Yes | The username to get the content | |
| slug | Yes | The slug to get the content |
Implementation Reference
- src/tools/status.ts:130-154 (handler)The handler function that executes the 'get content' tool logic, calling the API service and returning MCP formatted response.handler: async (params: GetContentParams): Promise<McpResponse> => { try { const result = await getContent({ username: params.username, slug: params.slug, }); const content: McpTextContent = { type: "text", text: `Content ${params.slug} from ${ params.username }:\n\n${JSON.stringify(result, null, 2)}`, }; return { content: [content], }; } catch (error) { if (error instanceof Error) { throw new Error(`Failed to get content: ${error.message}`); } else { throw new Error("Failed to get content"); } } },
- src/tools/status.ts:126-129 (schema)Zod schema defining input parameters for the 'get content' tool: username and slug.parameters: { username: z.string().describe("The username to get the content"), slug: z.string().describe("The slug to get the content"), },
- src/index.ts:45-50 (registration)Registration of the 'get content' tool with the MCP server using server.tool().server.tool( getContentTool.name, getContentTool.description, getContentTool.parameters, getContentTool.handler );
- src/services/api.ts:59-69 (helper)Helper function that performs the actual HTTP fetch to retrieve content from TabNews API.export async function getContent({ username, slug, }: GetContentParams): Promise<TabNewsContentWithBody> { const response = await fetch( `${TABNEWS_API_URL}/contents/${username}/${slug}` ); const data = await response.json(); return data as TabNewsContentWithBody; }
- src/types/index.ts:115-118 (schema)TypeScript interface defining the parameters for getting content.export interface GetContentParams { username: string; slug: string; }